﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xunit;
using M3G;

namespace MyTestProject {

    public class TestMaterial {
        [Fact]
        public void TestConstructor () {
            var mat = new Material ();

            Assert.Equal (0x00333333u, mat.Color[Material.Ambient]);
            Assert.Equal (0xffccccccu, mat.Color[Material.Diffuse]);
            Assert.Equal (0x00000000u, mat.Color[Material.Emissive]);
            Assert.Equal (0x00000000u, mat.Color[Material.Specular]);
            Assert.Equal (0.0f, mat.Shininess);
            Assert.Equal (false, mat.VertexColorTrackingEnabled);
        }

        [Fact]
        public void TestSetColor () {
            var mat = new Material ();
            mat.SetColor (Material.Ambient , 0x12345678);
            mat.SetColor (Material.Diffuse , 0x23456789);
            mat.SetColor (Material.Emissive, 0x34567890);
            mat.SetColor (Material.Specular, 0x45678901);

            Assert.Equal (0x00345678u, mat.Color[Material.Ambient]);
            Assert.Equal (0x23456789u, mat.Color[Material.Diffuse]);
            Assert.Equal (0x00567890u, mat.Color[Material.Emissive]);
            Assert.Equal (0x00678901u, mat.Color[Material.Specular]);
        }

        [Fact]
        public void TestSetShininess () {
            var mat = new Material ();
            mat.Shininess = 2.0f;

            Assert.Equal (2.0f, mat.Shininess);
        }

        [Fact]
        public void TestSetVertexColorTrackingEnabled () {
            var mat = new Material ();
            mat.VertexColorTrackingEnabled = true;

            Assert.Equal (true, mat.VertexColorTrackingEnabled);
        }

        [Fact]
        public void TestDuplicate () {
            var mat = new Material ();
            mat.SetColor (Material.Ambient, 0x12345678);
            mat.SetColor (Material.Diffuse, 0x23456789);
            mat.SetColor (Material.Emissive, 0x34567890);
            mat.SetColor (Material.Specular, 0x45678901);
            mat.Shininess = 2.0f;
            mat.VertexColorTrackingEnabled = true;
            mat.UserID = 100;

            var dup = (Material)mat.Duplicate ();

            Assert.Equal (mat.Color[Material.Ambient], mat.Color[Material.Ambient]);
            Assert.Equal (mat.Color[Material.Diffuse], mat.Color[Material.Diffuse]);
            Assert.Equal (mat.Color[Material.Emissive], mat.Color[Material.Emissive]);
            Assert.Equal (mat.Color[Material.Specular], mat.Color[Material.Specular]);
            Assert.Equal (mat.Shininess, mat.Shininess);
            Assert.Equal (mat.VertexColorTrackingEnabled, mat.VertexColorTrackingEnabled);
            Assert.Equal (100, mat.UserID);
        }
    }
}
